package com.client.eurekaclient.controller;

import com.bean.TestBean;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class MyController {



    @RequestMapping(value = "/c/info", method = RequestMethod.GET)
    public String info() {
        return "hello I am is spring-service-C1-INFO"; //测试代码直接返回一个字符串，不再调用service层等等。
    }

    @RequestMapping(value = "/c/send", method = RequestMethod.POST)
    public String send(String test, Long ll) {
        return test + "" +  ll; //测试代码直接返回一个字符串，不再调用service层等等。
    }

    @RequestMapping(value = "/c/send1", method = RequestMethod.POST)
    public TestBean send(@RequestBody TestBean test) {
        test.setId(test.getId() + "_1");
        return test; //测试代码直接返回一个字符串，不再调用service层等等。
    }

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public List<Map> list() {
        List<Map> data = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            Map m = new HashMap();
            m.put("i", i);
            data.add(m);
        }
        return data;
    }
}
